import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";
import { Repository } from "typeorm";

import { StockNode, StockNodeLink, StockNodeGateway, StockNodeLinkGateway } from "qqlx-core";
import { StockNodeSchema, StockNodeLinkSchema } from "qqlx-cdk";

import { PgDao } from "../../lib/dao.pg.id";

@Injectable()
export class StockNodeDao extends PgDao<StockNode> {
  constructor(
    @InjectRepository(StockNodeSchema)
    readonly repo: Repository<StockNode>,
  ) {
    super({
      repository: repo,
      relations_name: StockNodeGateway.relations,
    });
  }
}

@Injectable()
export class StockNodeLinkDao extends PgDao<StockNodeLink> {
  constructor(
    @InjectRepository(StockNodeLinkSchema)
    readonly repo: Repository<StockNodeLink>,
  ) {
    super({
      repository: repo,
      relations_name: StockNodeLinkGateway.relations,
    });
  }
}
